package com.xgjweb.common.utils;

import java.io.File;

public final class Constant {
	private Constant() {

	}

	// 系统根路径
	private static final String SYSTEM_ROOT_PATH = getSystenRootPath();
	// 文件后缀
	public static final String FILE_SUFFIX = ".rar";
	// 默认图片
	public static final String DEFAOULT_PIC = "default.jpg";
	// 无效图片
	public static final String NO_PIC = "noPic.jpg";
	// 相册路径
	public static final String ALBUM_PATH = getAlbumPath();
	// 相册路径
	public static final String LINK_PATH = getLinkPath();
	// 签名路径
	public static final String SIGN_PATH = getSignPath();
	// 图片路径
	public static final String PIC_PATH = getPicPath();

	/**
	 * 得到图片的根路径
	 * 
	 * @return
	 */
	private static String getPicPath() {
		String path = SYSTEM_ROOT_PATH + "flex" + File.separator + "image"
				+ File.separator + "userPic" + File.separator;
		return path;
	}

	/**
	 * 得到签名的路径
	 * 
	 * @return
	 */
	private static String getSignPath() {

		String path = SYSTEM_ROOT_PATH + "flex" + File.separator + "image"
				+ File.separator + "sign" + File.separator;
		return path;
	}

	/**
	 * 得到相册的路径
	 * 
	 * @return
	 */
	private static String getAlbumPath() {
		String path = SYSTEM_ROOT_PATH + "flex" + File.separator + "image"
				+ File.separator + "album" + File.separator;
		return path;
	}

	/**
	 * 得到相册的路径
	 * 
	 * @return
	 */
	private static String getLinkPath() {
		String path = SYSTEM_ROOT_PATH + "flex" + File.separator + "image"
				+ File.separator + "firendLink" + File.separator;
		return path;
	}

	/**
	 * 得到音乐的路径
	 * 
	 * @return
	 */
	private static String getSongPath() {
		String path = SYSTEM_ROOT_PATH + "flex" + File.separator + "music"
				+ File.separator;
		return path;
	}

	/**
	 * 得到系统的根流经
	 * 
	 * @return
	 */
	private static String getSystenRootPath() {
		String path = Constant.class.getResource("/").toString();
		return path.replaceAll("((file:/)|(WEB-INF/classes/))", "");
	}

	public static void main(String[] args) {
		System.out.println(Constant.class.getResource("/"));
		String path = Constant.class.getResource("/").toString();
		System.out
				.println(path.replaceAll("((file:/)|(WEB-INF/classes/))", ""));
		path = path.split("((:/)|(WEB-INF/classes))", 2)[1];
		// path=path.split("")
		System.out.println(path);
	}
}
